/*
 * @lc app=leetcode.cn id=461 lang=cpp
 *
 * [461] 汉明距离
 */

// @lc code=start
class Solution {
public:
    int hammingDistance(int x, int y) {
        // int XnotorY = x ^ y;
        // same(0,0)=0, diff(0,0)=1
        
        // int XandY = x & y;
        // int XorY = x | y;
        // <<
        // >>
        // int notX = ~x;

        // int diff = XandY - XorY; 
        int temp = x ^ y;
        int res = 0;
        while (temp != 0){
            // count bit 1

            // if bit is 0 
            // at the right end/at the far right
            // 0 & 1 = 0
            res += (temp & 1);

            // i forgot '='
            temp >>= 1;
        }
        return res;
    }
};
// @lc code=end

